package com.wangjiang.foundation.mybatis.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.wangjiang.foundation.mybatis.convert.ConvertFrom;
import com.wangjiang.foundation.mybatis.convert.ConvertTo;
import com.wangjiang.foundation.common.util.ClassUtil;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.Date;

public class BaseVO<E extends BaseEntity> implements Serializable, ConvertTo<E>, ConvertFrom<E> {
    @Getter
    @Setter
    private Long id;
    @Getter
    @Setter
    @JsonSerialize(using= ToStringSerializer.class)
    private String uuid;
    @Getter
    @Setter
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createdTime;
    @Getter
    @Setter
    private String createdById;
    @Getter
    @Setter
    private String createdByName;
    @Getter
    @Setter
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updatedTime;
    @Getter
    @Setter
    private String updatedById;
    @Getter
    @Setter
    private String updatedByName;
//
//    // 是否删除
//    private Boolean delFlag;

    // 启用停用
    @Getter
    @Setter
    private Boolean status;
    @Getter
    @Setter
    private String description;
    @Getter
    @Setter
    private String remark;

    /**
     * 输出时忽略属性
     *
     * @author wangjiang
     * @date 2021-01-05 10:09:13
     */
    @Getter
    @JSONField(serialize = false)
    @JsonIgnore
    private final Class<E> entityClass;

    public BaseVO() {
        this.entityClass = (Class<E>) ClassUtil.getGenericType(this.getClass(), 0);
    }
}
